import { defineStore } from "pinia";
import { ref } from 'vue'

// persist 进行数据持久化
export const useCounterStore =  defineStore('counter', () => {
	// 响应式的数据(state)
	const count = ref(0)
	
	const a = ref(0)
	const b = ref(0)
	
	// 定义方法,相当于(actions)
	function add(){
		count.value++
	}
	function dec(){
		count.value--
	}
	
	// 目的是外部能访问 count 这个响应式数据
	return { count,add,dec }
},{
	persist:{
		paths:['count']
	}
})
